package com.qky.controller.userController;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.qky.model.user.User;
import com.qky.service.baseService.BaseService;
import com.qky.util.MapUtil;
import com.qky.util.PageUtil;
import com.qky.util.http.HttpRequest;

@Controller
public class AddUserController {

	@Resource
	BaseService<User> uBaseService;
	
	/**
	 * 跳转到新增用户页面
	 * @return "user/addUser"
	 */
	@RequestMapping(value = "/addUser",method=RequestMethod.GET)
	public String addGet() {
		System.out.println(342);
		System.out.println("进入新增用户页面");
		return "user/addUser";
	}
	
	/**
	 * 执行新增用户操作
	 * @return "user/show1"
	 */
	@RequestMapping(value = "/addUser",method=RequestMethod.POST)
	public String upload(User user,
			HttpServletRequest request, ModelMap model) {  
		uBaseService.add(user);
		System.out.println("保存成功");
		PageUtil pageUtil=uBaseService.getUserListByPageUtil(1,10,User.class);
		model.put("pageUtil",1);
		model.put("pageIndex",10);
		model.put("pageUtil",pageUtil);
		return "user/showUser1"; 
	}
}
